import request from "@/utils/request";

/**
 * 获取所有单词
 */
export function getWordPage(data){
  return request({
    url: '/user/word/all',
    method: 'post',
    data
  })
}
/**
 * 获取当前用户已经默写的单词
 */
export function getDictationWord(data) {
  return request({
    url: '/user/word/dictationList',
    method: 'post',
    data
  })
}

/**
 * 开始默写
 */
export function start() {
  return request({
    url: '/user/dictationSession/start',
    method: 'post'
  })
}

/**
 * 匹配答案
 */
export function answer(id,word){
  return request({
    url: '/user/word/answer',
    method: 'get',
    params: {
      id,
      word
    }
  })
}

/**
 * 获取当前需要默写的单词
 */
export function getCurrentWord() {
  return request({
    url: '/user/word/getWord',
    method: 'get',
  })
}

/**
 * 结束默写
 */
export function endDictation() {
  return request({
    url: '/user/dictationSession/end',
    method: 'put'
  })
}

/**
 * 删除用户已经默写过的单词
 */
export function deleteDictationWord(id) {
  return request({
    url: `/user/userWord/${id}`,
    method: 'delete'
  })
}

/**
 * 收藏单词
 */
export function collect(id) {
  return request({
    url: '/user/userWord/collect',
    method: 'post',
    params: {id}
  })
}

/**
 * 取消收藏
 */
export function deleteCollect(id) {
  return request({
    url: `/user/userWord/collect/${id}`,
    method: 'delete'
  })
}

/**
 * 获取今天已经默写的单词
 */
export function getDailyWord() {
  return request({
    url: '/user/word/dailyWord',
    method: 'get'
  })
}
